<!--
<template>
    <div class="">
        <div class="row">
            <div class="col pr5">
                <video class="video" ref="myvideo" id="myvideo" muted></video>
            </div>
            <div class="col pl5">
                <video class="video" ref="youvideo" id="you"></video>
            </div>
        </div>
        <input v-model="userId">
        <input v-model="duifa">
        <van-button type="primary" class="" @click="getID">初始化</van-button>
        <van-button type="primary" class="" @click="bohao">拨号</van-button>
    </div>
</template>
<script>
    var peer = ''
    export default {
        data() {
            return {
                liu: '22',
                peer: '',
                userId: 'dx515235416',
                duifa: 'dx5152354167'
            }
        },
        computed: {

        },
        components: {

        },
        methods: {
            async getsd() {
                let res = await navigator.mediaDevices.getUserMedia({
                    video: true,
                    audio: true
                })
                this.$refs.myvideo.srcObject = res
            },
            getID() {
                this.$refs.myvideo.play()
                peer = new Peer(this.userId, {
                    host: "192.168.0.114",
                    port: "8089",
                    path: "/video",
                });
                peer.on("open", (id) => {
                    console.log("我的 id 是：" + id);
                })
                peer.on("call", (call) => {
                    this.$dialog.confirm({
                        title: '温馨提示',
                        message: call.peer+'来电是否接听',
                    }).then(() => {
                        call.answer(this.$refs.myvideo.srcObject);
                        call.on("stream", this.showVideo);
                    })

                });
            },
            async bohao() {
                const call = peer.call(this.duifa, this.$refs.myvideo.srcObject);
                call.on("stream", this.showVideo);
            },
            showVideo(se) {
                this.$refs.youvideo.srcObject = se;
                this.$refs.youvideo.play()
            }
        },
        mounted() {
            this.getsd()
        },
    }

</script>
<style scoped>
    .video {
        width: 100%;
        height: 200px;
        background: #000
    }

</style>
-->
